﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MedicalManagementAPP.Utils
{
    static class PatientManager
    {
        /// <summary>
        /// 获取所有病人的基本信息包括PatientID,PatientName,Phone,SignDate
        /// </summary>
        /// <returns>PatientID,PatientName,Phone,SignDate</returns>
        static public DataTable GetAllPatient()
        {
            DataTable result = null;
            string sql = "select PatientID,PatientName,Phone,SignDate from Patients order by PatientID desc";
            result = Connection.SqlQuery(sql);
            return result;
        }

        static public DataTable GetRecordSetsByID(string id)
        {
            DataTable result = null;
            string sql = "select RecordSetID,WorkerID,RecordDate,Describe from RecordSet where PatientID=@id order by RecordSetID desc";
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@id",id)
            };
            result = Connection.SqlQuery(sql, parameters);
            return result;
        }

        static public string GetDescribeByID(string id)
        {
            string result = null;
            string sql = "select Describe from RecordSet where RecordSetID=@id";
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@id",id)
            };
            DataTable data = Connection.SqlQuery(sql, parameters);
            result = data.Rows[0][0].ToString();
            return result;
        }


    }
}
